package com.feihao.zhou.dmeo02_IO;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileOutputStreamDemo02 {
    public static void main(String[] args) {
        //创建文件字节输出流
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream("H:\\Test\\123.txt", true);
            //向文件写入整数    ---》转换为码表对应的字符！！！
            fos.write(97);
            fos.write(98);

            fos.write("\r\n".getBytes());//换行

            fos.write("hello".getBytes());


            for (int i = 0; i < 10; i++) {
                fos.write(88);
                fos.write("\n".getBytes());
            }

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            //关闭流资源
            try {
                if (fos != null) {
                    fos.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
